<html>
<head><meta charset="utf-8"><title>desugaring vs. lowering · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/desugaring.20vs.2E.20lowering.html">desugaring vs. lowering</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="165458880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/desugaring%20vs.%20lowering/near/165458880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Phil H <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/desugaring.20vs.2E.20lowering.html#165458880">(May 12 2019 at 10:29)</a>:</h4>
<p>In AST-&gt;HIR and HIR-&gt;MIR conversion, the terms 'lowering' and 'desugaring' mean the same right? I've seen both used in various places and wasn't sure if there's a difference</p>



<a name="165459009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/desugaring%20vs.%20lowering/near/165459009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/desugaring.20vs.2E.20lowering.html#165459009">(May 12 2019 at 10:33)</a>:</h4>
<p>Not an expert at all, but I've always thought of it as desugaring also includes some transformations (e.g. in the AST-&gt;HIR, <code>?</code> is expanded into a <code>match</code>) whereas lowering is just converting from one representation to another.</p>



<a name="165459451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/desugaring%20vs.%20lowering/near/165459451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Phil H <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/desugaring.20vs.2E.20lowering.html#165459451">(May 12 2019 at 10:47)</a>:</h4>
<p>oh right, so IIUC lowering is the the general transformation and then there's additional desugarings on top like <code>for</code> loops  and <code>?</code></p>



<a name="165460146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/desugaring%20vs.%20lowering/near/165460146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/desugaring.20vs.2E.20lowering.html#165460146">(May 12 2019 at 11:09)</a>:</h4>
<p>yes, that's correct. Lowering can be from <code>ast::ExprKind::Binary</code> to <code>hir::ExprKind::Binary</code> without any changes to representation</p>



<a name="165460194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/desugaring%20vs.%20lowering/near/165460194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/desugaring.20vs.2E.20lowering.html#165460194">(May 12 2019 at 11:10)</a>:</h4>
<p>desugaring always means some sort of expansion into a reduced set of possible representations</p>



<a name="165476093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/desugaring%20vs.%20lowering/near/165476093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/desugaring.20vs.2E.20lowering.html#165476093">(May 12 2019 at 18:42)</a>:</h4>
<p>Depending on context, "desugaring" sometimes also refers to an in-language desugaring.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>